package com.dqp.cslggroup.UI;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.dqp.cslggroup.R;
import com.dqp.cslggroup.bean.course;

import java.util.List;

public class CouesrWidgetAdapter extends BaseAdapter {
    private List<course> courseList;
    private LayoutInflater inflater;
    private CouesrWidgetAdapter couesrWidgetAdapter;
    private Context context;

    public CouesrWidgetAdapter(List<course> courseList, Context context) {
        this.courseList = courseList;
        this.inflater = LayoutInflater.from(context);
        this.context = context;
    }

    @Override
    public int getCount() {
        return courseList == null ? 0 : courseList.size();
    }

    @Override
    public Object getItem(int position) {
        return courseList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        @SuppressLint({"ViewHolder", "InflateParams"}) View view = inflater.inflate(R.layout.course_widget_item, null);
        course course = (course) getItem(position);
        TextView kcmc = view.findViewById(R.id.course_widget_kcmc);
        TextView teacher = view.findViewById(R.id.course_widget_teacher);
        TextView time = view.findViewById(R.id.course_widget_time);
        TextView room = view.findViewById(R.id.course_widget_room);
        kcmc.setText(course.getKcmc());
        teacher.setText(course.getXm());
        time.setText(course.getJc());
        room.setText(course.getCdmc());
        return view;
    }

}
